package com.soft.springhrms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.soft.springhrms.pojo.Salaries;
import com.soft.springhrms.pojo.SystemLogs;
import com.soft.springhrms.service.SystemLogsService;
import com.soft.springhrms.mapper.SystemLogsMapper;
import com.soft.springhrms.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author DELL
 * @description 针对表【system_logs】的数据库操作Service实现
 * @createDate 2024-11-16 18:48:18
 */
@Service
public class SystemLogsServiceImpl extends ServiceImpl<SystemLogsMapper, SystemLogs>
        implements SystemLogsService {
    @Autowired
    private SystemLogsMapper systemLogsMapper;
    @Override
    public void saveLogs(SystemLogs log) {
        systemLogsMapper.insert(log);
    }

    @Override
    public ResultVO getLogs(Integer pageNum, Integer pageSize) {
        Page<SystemLogs> page = new Page<>(pageNum, pageSize);
        // 执行分页查询
        IPage<SystemLogs> resultPage = systemLogsMapper.selectPage(page, null);
        // 判断结果是否为空
        if (resultPage.getRecords().isEmpty()) {
            return ResultVO.success(resultPage, "暂无数据");
        }
        // 直接使用查询结果，不需要手动复制
        return ResultVO.success(resultPage, "查询成功");
    }
}




